package com.foreverwin.mes.meapi.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.foreverwin.mes.core.base.FrontPage;
import com.foreverwin.mes.meapi.mapper.InventoryMapper;
import com.foreverwin.mes.meapi.model.Inventory;
import com.foreverwin.mes.meapi.service.InventoryService;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Ervin Chen
 * @since 2020-02-03
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory> implements InventoryService {


    @Autowired
    private InventoryMapper inventoryMapper;

    @Override
    public Page<Inventory> selectPage(FrontPage<Inventory> frontPage, Inventory inventory) {
        EntityWrapper<Inventory> queryWrapper = new EntityWrapper<>();
        queryWrapper.setEntity(inventory);
        return super.selectPage(frontPage.getPagePlus(), queryWrapper);
    }

    @Override
    public List<Inventory> selectList(Inventory inventory) {
        EntityWrapper<Inventory> queryWrapper = new EntityWrapper<>();
        queryWrapper.setEntity(inventory);
        return super.selectList(queryWrapper);
    }

    @Override
    public List<Inventory> listByAssyData(Wrapper<Inventory> entityWrapper, String dataField, String dataAttr) {
        return inventoryMapper.selectListByAssyData(entityWrapper, dataField, Lists.newArrayList(dataAttr));
    }

    @Override
    public List<Inventory> listByAssyData(Wrapper<Inventory> entityWrapper, String dataField, List<String> dataAttrs) {
        return inventoryMapper.selectListByAssyData(entityWrapper, dataField, dataAttrs);
    }

}